<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1">
    <meta content=always name=referrer>
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/newbase.css">
    <script src="__STATIC__/js/jquery-1.8.2.js"></script>
    <title>分销订单</title>
</head>
{include file="public/href" /}
<body>
<div class="wrap-fx">
    <div class="header">
        <p>分销订单</p>
        <img src="__STATIC__/img/back.png" class="back" onclick="history.go(-1)">
    </div>
    <div class="center" id="content_list">
    </div>
</div>
{include file="public/src" /}
<script>
    //layer流加载
    layui.use('flow', function() {
        var $ = layui.jquery;
        var flow = layui.flow;
        flow.load({
            elem: '#content_list' //流加载容器
            ,isAuto:true
            ,isLazyimg:true
            ,done: function(page, next){ //执行下一页的回调
                var lis = [];
                $.ajax({
                    url:"{:url('mobile/user_info/distribution_order')}",
                    dataType:'json',
                    type:'post',
                    data:{'page':page,'member_id':"{:input('member_id')}"},
                    success:function(t){
                        layui.each(t.data, function(index, item){
                            var nickname = '未设置';
                            if (item.nickname){
                                nickname = item.nickname;
                            }
                            var text = '';
                            for (var i=0; i < item.list.length; i++){
                                    if (item.list[i]['brokerage']>0) {
                                        text += '<tr>' +
                                            '<td>'+item.list[i]['order_time']+'</td>' +
                                            '<td>'+item.list[i]['pay_time']+'</td>' +
                                            '<td>'+item.list[i]['price']+'</td>' +
                                            '<td>'+item.list[i]['brokerage']+'</td>' +
                                            '</tr>';
                                    }

                            }
                            lis.push('<p><a href="javascript:void(0);">昵称：'+nickname+'</a>' +
                                        '<span><a href="javascript:void(0);">佣金：'+item.total_brokerage+'元</a></span>' +
                                    '</p>' +
                                    '<table border="0">' +
                                        '<tr>' +
                                            '<td>订单时间</td>' +
                                            '<td>付款时间</td>' +
                                            '<td>订单金额</td>' +
                                            '<td>产生佣金</td>' +
                                        '</tr>' +
                                            text+
                                    '</table>');
//
                        });
                        next(lis.join(''), page < t.pages);
                    },
                    error: function () {
                        layer.open({content:'网络繁忙,请重试',skin:'msg',time:2});
                    }
                })
            }
        });
    });
    //获取对象/数组实际长度
    function count(obj){
        var objType = typeof obj;
        if(objType == "string"){
            return obj.length;
        }else if(objType == "object"){
            var objLen = 0;
            for(var i in obj){
                objLen++;
            }
            return objLen;
        }
        return false;
    }
</script>
</body>
</html>